<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        img {
            width: 300px;
        }
    </style>
</head>

<body>
<button id="ldh">刘德华</button>
<button id="zxy">张学友</button>
<br>
<img src="images/ldh.jpg" alt="" title="刘德华">

<script>
    // 修改元素属性  src
    // 1. 获取元素
    const ldh = document.getElementById('ldh');
    const zxy = document.getElementById('zxy');
    const img = document.querySelector('img');
    // 2. 注册事件  处理程序
    zxy.onclick = function () {
        img.src = 'images/zxy.jpg';
        img.title = '张学友思密达';
    }
    ldh.onclick = function () {
        img.src = 'images/ldh.jpg';
        img.title = '刘德华';
    }
</script>
</body>

</html>
